#pragma once

class SolarSystem;

struct EExplorerType
{
	enum Type
	{
	    Universe = 0,
	    Star
	};
};

/*--------------------------------------------------------------------------*/

struct Explorer
{
	SceneInstance*		m_scene;
	PerspectiveCamera*	m_camera;
	std::string			m_name;
	EExplorerType::Type m_type;
	GLTexture*			m_output;
	ICelestial*			m_owner;
	uint		m_depth;

	Explorer() :
		m_camera(NULL),
		m_scene(NULL),
		m_type(EExplorerType::Universe),
		m_owner(NULL),
		m_depth(0)
	{}
};

/*--------------------------------------------------------------------------*/

#define CEXPLORER_MAX_DEPTH 5

/*--------------------------------------------------------------------------*/

class CExplorer :
	public IGameMode,
	public ICalc,
	public IRender
{
public:
	CExplorer();
	~CExplorer();

	/*--IGameMode---------------------------------------------------------------*/
	void	InitGameMode();

	/*--ICalc-------------------------------------------------------------------*/
	void	OnCalc(uint arg);

	/*--IRender-----------------------------------------------------------------*/
	void	OnRender(const RenderTask* renderTask, uint camarg);

	/*--------------------------------------------------------------------------*/

	void	Push(ICelestial* src, ECelestialType::Type type, void* initData, const glm::vec3& vector);
	void	Pop(const glm::vec3& vector);

	void	Log();
	void	NavigateTo(uint i);

private:
	// scena rodzic przestaje malowac obiekt, jest on malowany w scenie-dziecku
	void	PushCelestial(ICelestial* toClone, ECelestialType::Type type, void* initData, const glm::vec3& vector);
	void	PopCelestial(const glm::vec3& vector);

	/*--------------------------------------------------------------------------*/
	bool					m_pendingPopData;
	glm::vec3				m_pendingPopVector;

	bool					m_pendingPushData;
	ICelestial*				m_src;
	ECelestialType::Type	m_type;
	void*					m_initData;
	glm::vec3				m_pendingPushVector;
	/*--------------------------------------------------------------------------*/
	bool					m_navigation;
	uint			m_navId;

	/*--------------------------------------------------------------------------*/

	std::list<Explorer>		m_celestialsStack;
	GLTexture*				m_outputTextures[CEXPLORER_MAX_DEPTH];
};

namespace sh
{
void explorer();
void navigateto(uint i);
};

extern CExplorer* g_Explorer;